<template>
	<view class="container">
		<view class="" style="background-color: #fff;padding: 0 30rpx;">
			<view class="index-header">
				<view class="header_addr">
					<image src="/static/image/Index/addr-icon.png" mode="" class="addr_icon"></image>
					<span class="addr_txt">郑州市</span>
					<image src="/static/image/Index/down-icon.png" mode="" class="down_icon"></image>
				</view>
				<!-- <view class="header_search">
					<image src="/static/image/Index/index-search.png" mode="" @click="switchSearch" class="search_icon">
					</image>
				</view> -->
			</view>
			<!-- 导航 -->
			<view class="index-tabs">
				<view class='active' v-for="(item,index) in tabList" :key="index">
					<view :class="{texted:currentTab == index }" :data-tab="item.value" @click="switchTab(index)">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<view class="" v-show="currentTab == 0">
			<noData style="margin: 0 auto;" v-if="lists.length < 1" :ndText="'暂无组局数据'"></noData>
			<view v-else class="active-one-lists"
				@click="$helper.to('/pages/tabBar/activity/activeDetail/activeDetail?id='+item.id)"
				v-for="(item,ind) in lists" :key="ind">
				<view class="active-one-lists-head">
					<view class="active-one-lists-head-box">
						<image class="active-one-lists-head-img" :src="item.user.avatar" mode="">
						</image>
						<view class="active-one-lists-head-middle">
							<view class="active-one-lists-head-middle-top">
								<view class="name">
									{{item.user.user_nickname}}
								</view>
								<image class="girl-img"
									:src="item.user.gender == 1 ? '/static/image/Index/boy-icon.png' :'/static/image/Index/girl-icon.png'">
								</image>
								<image v-show="item.user.is_vip == true" class="vip-img"
									src="/static/image/Index/VIP-icon.png" mode=""></image>
							</view>
							<view class="active-one-lists-head-middle-bottom">
								搭子需求：{{item.demand}}
							</view>
						</view>
					</view>
					<view class="active-one-lists-head-right" @click.stop="bm(item)">
						{{item.is_sign == true ? '已报名' : '报名'}}
					</view>
				</view>
				<view class="active-one-lists-contet">
					{{item.content}}
				</view>
				<view class="active-one-lists-bottom">
					<view class="active-one-lists-bottom-left">
						<image :src="item.imgBg" mode=""></image>
						<view class="lable">
							{{item.type}}
						</view>
					</view>
					<view class="active-one-lists-bottom-right">
						<view class="active-one-lists-bottom-right-title">{{item.title}}</view>
						<view class="active-one-lists-bottom-right-time">
							<image src="/static/image/activity/time.png" mode=""></image>
							<view class="">{{item.start_time}}-{{item.end_time}}</view>
						</view>
						<view class="active-one-lists-bottom-right-address">
							<image src="/static/image/activity/top.png" mode=""></image>
							<view class="">{{item.address}}</view>
						</view>
						<!-- 	<view class="active-one-lists-bottom-right-address">
							<image src="/static/image/activity/bottom.png" mode=""></image>
							<view class="">二七区航海路北100米建业小区 </view>
						</view> -->
						<view class="active-one-lists-bottom-right-price">
							<text
								style="color: #FF0000;font-size: 30rpx;">￥{{item.min_price}}-{{item.max_price}}人</text>
							<text style="color: #999999;font-size: 24rpx;margin: 0 15rpx;">0/{{item.number}}</text>
							<text style="color: #999999;font-size: 24rpx;">距我158.2km</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-show="currentTab == 1">
			<noData style="margin: 0 auto;" v-if="sjLists.length < 1" :ndText="'暂无商家数据'"></noData>
			<view v-else class="active-one-lists" v-for="(it,int) in sjLists" :key="int">
				<view class="active-one-lists-bottom">
					<view class="active-one-lists-bottom-left">
						<image :src="it.logo" mode=""></image>
					</view>
					<view class="active-one-lists-bottom-right">
						<!-- <view class="active-one-lists-bottom-right-title">头道汤·养生馆</view> -->
						<view class="active-one-lists-bottom-right-title flex justify-between">
							<view class="flex">
								<view class="">{{it.name}}</view>
								<view
									style="color: #FEC92F;font-weight: bold; font-size: 30rpx;margin: 8rpx 0 0 15rpx;">
									{{it.score}}
								</view>
							</view>
							<view style="font-size: 22rpx;color: #666666;margin-top: 16rpx;">
								{{it.distance}}
							</view>
						</view>
						<view class="active-one-lists-bottom-right-time">
							<image src="/static/image/activity/time.png" mode=""></image>
							<view class="">营业时间：{{it.hours}}</view>
						</view>
						<view class="active-one-lists-bottom-right-address">
							<image src="/static/image/activity/address.png" mode=""></image>
							<view class="">{{it.address}}</view>
						</view>
						<view class="active-one-lists-bottom-right-price flex justify-between">
							<view class="">
								<text style="color: #FF0000;font-size: 30rpx;">￥{{it.avg_price}}/人均</text>
								<text
									style="color: #999999;font-size: 24rpx;margin-left: 10rpx;">已售{{it.virtual_sales}}</text>
							</view>
							<view class="active-one-lists-bottom-right-btnss"
								@click="$helper.to('/pages/tabBar/activity/activitySjDetail/activitySjDetail?id='+it.id)">
								立即下单
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<image v-show="currentTab == 0" @click.stop="$helper.to('/pages/tabBar/activity/createActivity/createActivity')"
			class="f-img" src="/static/image/activity/fa.png" mode=""></image>
	</view>
</template>

<script>
	import noData from '@/components/ben-components/notData/notData.vue'
	import loadMoreMixin from '@/utils/load-more-mixin.js';
	export default {
		mixins: [loadMoreMixin],
		components: {
			noData
		},
		data() {
			return {
				currentTab: 0,
				tabList: [{
						name: '组局',
						value: 0
					},
					{
						name: '商家',
						value: 1
					}
				],
				lists: [],
				sjLists: [],
			}
		},
		onShow() {
			this.switchTab(0);
		},
		methods: {
			// tab切换
			switchTab(index) {
				this.lists = [];
				this.sjLists = [];
				this.currentTab = index;
				if (index == 0) {
					this.getDzList();
				} else {
					this.getdpList();
				}
			},
			getdpList() {
				this.$http.dpList().then(res => {
					if (res.code == '1') {
						this.sjLists = res.data.data;
					}
				})
			},
			// 获取搭子列表
			getDzList() {
				let params = {
					page: 1,
					list_rows: 10,
				}
				uni.showLoading({
					title: '加载中'
				});
				this.$http.getDzList(params).then(res => {
					uni.stopPullDownRefresh();
					uni.hideLoading();
					if (res.code == '1') {
						res.data.data.map(item => {
							item.imgBg = item.url.split('，')[0]
						})
						this.lists = this.lists.concat(res.data.data);
						this.total = res.data.total;
						this.loadStatus = this.len < this.total ? 'more' : 'noMore';
						// this.lists = res.data.data
					}
				})
			},
			// 报名
			bm(info) {
				uni.navigateTo({
					url: `/pages/TUIKit/TUI-Chat/chat?conversationID=C2C${info.user_id}`
				});
				return
				if (info.is_sign == true) return this.$helper.toast('none', '您已报名，请勿重复报名!')
				this.$http.getDzLisBm({
					id: info.id
				}).then(res => {
					if (res.code == '1') {
						
						this.$helper.toast('none', '报名成功!')
						this.getDzListDetail()
						uni.navigateTo({
							url: `/pages/TUIKit/TUI-Chat/chat?conversationID=C2C${info.user_id}`
						});
					} else {
						this.$helper.toast('none', res.msg)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #F8F8F8;
	}

	.f-img {
		width: 40rpx;
		height: 40rpx;
		position: fixed;
		top: 50%;
		right: 20rpx;
	}

	.container {
		.index-header {
			display: flex;
			justify-content: space-between;
			background-color: #fff;
		}

		.header_addr {
			display: flex;
			align-items: center;

			.addr_icon {
				width: 24rpx;
				height: 32rpx;
			}

			.addr_txt {
				font-size: 26rpx;
				margin: 0 12rpx;
				color: #000;
			}

			.down_icon {
				width: 14rpx;
				height: 10rpx;
			}
		}

		.header_search {
			display: flex;
			align-items: center;

			.search_icon {
				width: 31rpx;
				height: 34rpx;
				margin-right: 30rpx;
			}

			.filter_icon {
				width: 32rpx;
				height: 32rpx;
				margin-right: 20rpx;
			}
		}

		.index-tabs {
			display: flex;
			align-items: center;
			margin-top: 40rpx;
		}

		.active {
			font-size: 32rpx;
			margin-right: 40rpx;
			color: #666666;
		}

		.texted {
			font-size: 40rpx;
			color: #000;
		}
	}

	.active-one-lists {
		padding: 20rpx;
		background-color: #fff;
		margin-bottom: 20rpx;
	}

	.active-one-lists-head {
		display: flex;
		justify-content: space-between;
		margin-top: 30rpx;

		.active-one-lists-head-box {
			display: flex;
		}

		.active-one-lists-head-img {
			width: 68rpx;
			height: 68rpx;
			border-radius: 50%;
		}

		.active-one-lists-head-middle {
			margin-left: 10rpx;

			.active-one-lists-head-middle-top {
				display: flex;
				align-items: center;

				.name {
					font-weight: 500;
					font-size: 28rpx;
					color: #333333;
				}

				.girl-img {
					width: 22rpx;
					height: 22rpx;
					margin: 0 10rpx;
				}

				.vip-img {
					width: 44rpx;
					height: 22rpx;
				}
			}

			.active-one-lists-head-middle-bottom {
				font-weight: 400;
				font-size: 20rpx;
				color: #999999;
			}
		}

		.active-one-lists-head-right {
			width: 128rpx;
			height: 50rpx;
			border-radius: 20rpx;
			text-align: center;
			line-height: 50rpx;
			background-color: #000;
			color: #FEC92F;
			font-size: 24rpx;
			margin-right: 10rpx;
		}
	}

	.active-one-lists-contet {
		font-weight: 400;
		font-size: 26rpx;
		color: #000000;
		margin: 16rpx 0;
	}

	.active-one-lists-bottom {
		display: flex;
		position: relative;

		.active-one-lists-bottom-left {
			width: 250rpx;
			height: 250rpx;

			image {
				width: 100%;
				height: 100%;
			}

			.lable {
				position: absolute;
				width: 80rpx;
				height: 36rpx;
				top: 0;
				left: 0;
				color: #fff;
				font-size: 20rpx;
				background-color: #999;
				text-align: center;
			}
		}

		.active-one-lists-bottom-right {
			margin-left: 10rpx;

			.active-one-lists-bottom-right-title {
				font-weight: 500;
				font-size: 30rpx;
				color: #000000;
			}

			.active-one-lists-bottom-right-time {
				align-items: center;
				margin: 10rpx 0;
				display: flex;
				font-size: 24rpx;
				color: #999999;

				image {
					width: 24rpx;
					height: 24rpx;
					margin-right: 10rpx;
				}
			}

			.active-one-lists-bottom-right-btnss {
				width: 156rpx;
				height: 56rpx;
				text-align: center;
				line-height: 56rpx;
				font-size: 24rpx;
				color: #FEC92F;
				background-color: #000;
				border-radius: 20rpx;
			}

			.active-one-lists-bottom-right-address {
				display: flex;
				font-size: 24rpx;
				color: #999999;
				margin: 10rpx 0;

				image {
					width: 24rpx;
					height: 24rpx;
					margin-right: 10rpx;
					margin-top: 7rpx;
				}
			}
		}
	}
</style>